<?php
declare(strict_types=1);
namespace App\Controller\Web;

use App\Controller\AbstractController;
use App\Core\Response;
use App\Services\SessionService;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Hyperf\Contract\SessionInterface;
use Hyperf\Di\Annotation\Inject;
use Hyperf\View\RenderInterface;
use Psr\SimpleCache\CacheInterface;

class BaseController extends AbstractController
{
    /**
     * @Inject
     * @var ResponseInterface
     */
    protected $response;

    /**
     * @Inject
     * @var RenderInterface
     */
    protected $render;

    /**
     * @Inject
     * @var SessionInterface
     */
    public $session;

    /**
     * @Inject
     * @var CacheInterface
     */
    protected $cache;

    /**
     * @Inject
     * @var Response
     */
    protected $apiReponse;

    /**
     * @Inject
     * @var SessionService
     */
    protected $sessionService;

    public function __construct(SessionInterface $session)
    {
        $this->session = $session;
    }

    public function view($template,$data=[])
    {
        $data['user'] = $this->sessionService->get('user');
        return $this->render->render($template,$data);
    }
}